package corej.course.collection.list.arraylist;

public class Employee implements Comparable {

    private String name;
    private int age;
    private double salary;

    /**
     * @param name
     * @param age
     * @param salary
     */
    public Employee(String name, int age, double salary) {
        super();
        this.name = name;
        this.age = age;
        this.salary = salary;
    }

    /*
      * (non-Javadoc)
      *
      * @see java.lang.Comparable#compareTo(java.lang.Object)
      */
    public int compareTo(Object o) {

        Employee man = (Employee) o;

        //�Ӵ���С�ŵģ����Է���ֵ�෴
        if (this.salary > man.salary)
            return -1;
        if (this.salary < man.salary)
            return 1;
        if (this.age > man.age)
            return -1;
        if (this.age < man.age)
            return 1;
        else
            return this.name.compareTo(man.name) * (-1);
    }

    public String toString() {
        return "Employee name: " + name + ", age: " + age + ", salary: "
                + salary;
    }

}
